# coding=utf-8
import cPickle as pickle
import json
import pandas
import types
import pymongo

client = pymongo.MongoClient("localhost", 27017)
db = client.quant_data
name = db.name

print 'conncat mongo %s ' % name;

result = {};
fr = open('./result/result.pkl');
data_dict = pickle.load(fr);

for (k, v) in data_dict.items():

    if (type(v) == type({})):
        result[k] = json.dumps(v);
    else:
        result[k] = pandas.DataFrame.to_json(v);
fr.close();
print db.users.insert_one(result).inserted_id
